package com.xbongbong.pro.statistic.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
 * 范围选择类型枚举
 * @author 梅伟丁
 * @date 2022/5/13 14:24:31
 * @version 1.0
 */
@Getter
public enum RangeSelectionTypeEnum {

    /**
     * USER，筛选类型为员工
     */
    USER(1,"user"),
    /**
     * DEPARTMENT，筛选类型为部门
     */
    DEPARTMENT(2,"department"),
    /**
     * ALL，筛选类型为部门和人员
     */
    ALL(3,"all"),
    /**
     * UNKNOWN，此项代表未筛选
     */
    UNKNOWN(404,"unknown"),
    ;

    /** 枚举值 -- */
    private final int code;
    /** 枚举描述 --*/
    private final String name;

    RangeSelectionTypeEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code获取枚举
     * @return
     */
    public static RangeSelectionTypeEnum getByCode(Integer code) {
        if (code == null) {
            return UNKNOWN;
        }
        for (RangeSelectionTypeEnum cache : values()) {
            if (code == cache.getCode()) {
                return cache;
            }
        }
        return UNKNOWN;
    }
}
